// JavaScript Document
/**
 * Created by wangfan on 2017/5/21.
 */

function getUrl(url, params) {
    for (var i = 0; i < params.length; i++) {
        if ($("#" + params[i]).val() != "") {
            url = url + "&" + params[i] + "=" + $("#" + params[i]).val();
        }
    }
    return url;

}
function getUrlParam(name) {
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r!=null) return unescape(r[2]); return null; //返回参数值
}
function countNotify(result,type) {
    var count =
        parseInt(result.data.allBackNotify)+
        parseInt(result.data.addProNotify)+
        parseInt(result.data.attNotify)+
        parseInt(result.data.overtimeNotify)+
        parseInt(result.data.delProNotify)+
        parseInt(result.data.fundNotify)+
        parseInt(result.data.fundCommunityNotify)+
        parseInt(result.data.officeCommunityNotify)+
        parseInt(result.data.publicFundCommunityNotify)+
        parseInt(result.data.constructionCommunityNotify)+
        parseInt(result.data.publicFundOrgNotify)+
        parseInt(result.data.constructionOrgNotify)+
        parseInt(result.data.officeNotify)+
        parseInt(result.data.publicFundNotify)+
        parseInt(result.data.constructionNotify)
    ;

    if(type){
        if(0===count){

            $('#xxsl').hide();
        }else{
            $('#xxsl').show();
            $('#xxsl').html(count);
        }

    }else{
        if (0 === count) {
            window.parent.$('#xxsl').hide();
        } else {
            window.parent.$('#xxsl').show();
            window.parent.$('#xxsl').html(count);
        }

    }

    return count;


}

function formatStringyyyyMMddTochinese (value){
    if(value.length >=10){
        return value.substring(0, 4) + "年" + value.substring(5, 7) + "月" + value.substring(8, 10)+ "日";
    } else if(value.length == 7){
        return value.substring(0, 4) + "年" + value.substring(5, 7);
    } else {
        return value;
    }
}
function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
        + " " + date.getHours() + seperator2 + date.getMinutes()
        + seperator2 + date.getSeconds();
    return currentdate;
}

function getNowFormatDateShort() {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
        + "" ;
    return currentdate;
}